package client.block;

import common.block.AbstractBlock;
import org.lwjgl.opengl.GL11;

import java.util.Map;

public class BlockTextureLoader {

    private int[] textureIds = new int[0];

    public void load(Iterable<IBlockModel> blocks) {
        MultiBlockAtlasBuilder builder = new MultiBlockAtlasBuilder(1);
        for (IBlockModel block : blocks) {
            Map<String, String> textures = block.getTextures();
            AbstractBlock object = block.getBlock();
            textures.forEach((name, path) -> builder.put(object, name, path));
        }
        textureIds = builder.end();
    }

    public void delete() {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
        GL11.glDeleteTextures(textureIds);
    }

    private void onAtlasCreate(AbstractBlock block, BlockTextureAtlas atlas) {

    }
}
